﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Tong;

public partial class aspnet_admin_bock_Iask_Create : System.Web.UI.Page
{
    /// <summary>
    /// 爱问的实列
    /// </summary>
    public Tong.IAsk.IaskDataOrstr Ask = new Tong.IAsk.IaskDataOrstr();
    /// <summary>
    /// 数据操作通用类 实例 TextData
    /// </summary> 
    public TongUse TextData = new TongUse();

    /// <summary>
    /// 系统安装绝对路径
    /// </summary>
    public string Abs_Path = TongUse.SysPath;
    /// <summary>
    /// 用户存放数据的临时表
    /// </summary>
    DataTable MyDt = new DataTable();


    /// <summary>
    /// 站点通用方法类
    /// </summary>
    public Tong.ThisSiteUse.SiteTong TextThisSite = new Tong.ThisSiteUse.SiteTong();

    string err = "";



    protected void Page_Load(object sender, EventArgs e)
    {

    }
    /// <summary>
    /// 生成分类
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button2_Click(object sender, EventArgs e)
    {
        MyDt = TextData.SqlataSet("select * from [ask_Column] ").Tables[0];
        tt.Text = "";
        for (int i = 0; i < MyDt.Rows.Count; i++)
        {
            try
            {
                TextData.DirCreate(Server.MapPath(MyDt.Rows[i]["CX_Column_Directory"].ToString()+"C/")) ;//创建文件夹

                Ask.GetWebDataWrite("/IAsk/QuestionList.aspx" + "?CoulmnID=" + MyDt.Rows[i]["CX_Column_id"].ToString(), Server.MapPath(MyDt.Rows[i]["CX_Column_Directory"].ToString() + "C/" + MyDt.Rows[i]["CX_Column_id"].ToString() + ".html"));

            }
            catch (Exception ex)
            {
                err += "   " + MyDt.Rows[i]["CX_Column_id"].ToString();

            }
        }
        MyDt.Clear();
        MyDt.Dispose();
        tt.Text += "生成成功";
        if (err != "")
        {
            tt.Text = Err;
        }
    }

    /// <summary>
    ///  错误
    /// </summary>
    public string Err
    {
        get {

            string uu = "出错:"+err;
            err = "";
            return uu; }
        set { err = value; }
    }

    /// <summary>
    /// 生成问题
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button3_Click(object sender, EventArgs e)
    {
        MyDt = TextData.SqlataSet("select * from [ask_query] ").Tables[0];
        tt.Text = "";
        string htmlpath = "/Iask/html/";
        for (int i = 0; i < MyDt.Rows.Count; i++)
        {
            try
            {
                TextData.DirCreate(htmlpath);//创建文件夹

                Ask.GetWebDataWrite("/IAsk/AnswerList.aspx" + "?id=" + MyDt.Rows[i]["ask_query_id"].ToString(), Server.MapPath(htmlpath + MyDt.Rows[i]["ask_query_id"].ToString() + ".html"));

            }
            catch (Exception ex)
            {
                err += "   " + MyDt.Rows[i]["ask_query_id"].ToString();

            }
        }
        MyDt.Clear();
        MyDt.Dispose();
        tt.Text = "生成成功";
        if (err != "")
        {
            tt.Text = Err;
        }
    }
    /// <summary>
    /// 生成爱问首页
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button4_Click(object sender, EventArgs e)
    {
        string htmlpath = "/Iask/html/";
            try
            {
                TextData.DirCreate(htmlpath);//创建文件夹
                Ask.GetWebDataWrite("/IAsk/WebMainPage.aspx", Server.MapPath(htmlpath + "index.html"));
                Ask.GetWebDataWrite("/IAsk/WebMainPage.aspx", Server.MapPath("/IAsk/" + "index.html"));
            }
            catch (Exception ex)
            {
                err += "   " ;
            }

        MyDt.Clear();
        MyDt.Dispose();
        tt.Text = "生成成功";
        if (err != "")
        {
            tt.Text = Err;
        }
    }
    /// <summary>
    /// 生成分类页面
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button5_Click(object sender, EventArgs e)
    {
        string htmlpath = "/Iask/html/";
        try
        {
            TextData.DirCreate(htmlpath);//创建文件夹
            Ask.GetWebDataWrite("/IAsk/WebMainPage.aspx" + "?id=", Server.MapPath(htmlpath + "Class.html"));
            Ask.GetWebDataWrite("/IAsk/ClassShow.aspx" + "?id=", Server.MapPath("/IAsk/" + "Class.html"));
        }
        catch (Exception ex)
        {
            err += "   ";
        }

        MyDt.Clear();
        MyDt.Dispose();
        tt.Text = "生成成功";
        if (err != "")
        {
            tt.Text = Err;
        }
    }
}
